package com.moyu.plugins.pokemsg.Command;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import com.moyu.plugins.pokemsg.PokeMsg;

public class PMsgCommandExecutor implements CommandExecutor {
	
	private final PokeMsg plugin;
	
	public PMsgCommandExecutor (PokeMsg plugin)
	{
		this.plugin = plugin;
	}

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		if (label.equalsIgnoreCase("pmsg"))
		{
			if(args.length == 0)
			{
				sender.sendMessage("§6[宝可梦公告]§a指令帮助§b(v2.1)");
				sender.sendMessage("§a/pmsg reload             §e——重载配置文件");
			}
			else if(args[0].equals("reload"))
			{
				if ( (args.length == 1) && sender.isOp() )
				{
					plugin.reloadConfig();
					sender.sendMessage("§6[宝可梦公告]§a配置已重载！");
				}
			}
			else
			{
				sender.sendMessage("§6[宝可梦公告]§a指令帮助§b(v2.1)");
				sender.sendMessage("§a/pmsg reload             §e——重载配置文件");
			}
			return true;
		}
		return false;
	}

}
